package org.dwpd.domain.common;

import lombok.Data;

@Data
public class Result {

    private int code; // 业务状态码
    private String msg; // 错误时返回的信息
    private Object data; // 业务返回的数据
    /**
     * 业务执⾏成功时返回的⽅法
     * @param data
     * @return
     */
    public static Result success(Object data) {

        Result result = new Result();
        result.setCode(Code.RESULT_CODE_SUCCESS);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    /**
     * 业务执⾏失败时返回的⽅法
     *
     * @param
     * @return
     */
    public static Result fail(int code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg); // 这里的msg为报错原因
        result.setData("");
        return result;
    }
    /**
     * ⽤⼾未登录时返回的⽅法
     *
     * @param
     * @return
     */
    public static Result unlogin(int code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData("");
        return result;
    }

}
